1 <?php
2 ob_start();
3 include(
"header.php");
4 include(
"sidebar.php");
5 ?>
6 <script type=
"text/javascript">
7 function isNumberKey(evt)
8       {
9
10          
var charCode = (evt.which) ? evt.which : event.keyCode
11         
//alert(charCode);
12          
if (charCode > 63 && charCode < 92 )
13          {
14          
return true;
15      }
16      
else if (charCode > 96 && charCode < 123 )
17          {
18          
return true;
19      }
20      
else
21      {
22                              alert(
"should be alphabet");
23         
return false;
24      }
25      }
26 function validate()
27 {

28 if
(document.form1.fname.value=="")
29 {
30     alert(
"Enter First Name");
31     document.form1.fname.focus();
32     
return false;
33 }

34 if
(document.form1.lname.value=="")
35 {
36     alert(
"Enter Last Name");
37     document.form1.lname.focus();
38     
return false;
39 }

40 if
(document.form1.email.value=="")
41 {
42     alert(
"Enter Email ID");
43     document.form1.email.focus();
44     
return false;
45 }
46 ml = document.form1.email.
value;
47         pos1 = ml.indexOf(
"@")
48         pos = ml.indexOf(
" ")
49         pos2 = (pos1+
1)
50         server = ml.substring(pos2);
51         server_pos = server.lastIndexOf(
".")
52         reqtype = server.substring(server_pos+
1)
53         type_end = reqtype.substring(reqtype.length-
1)
54
55 if
(ml.length<8)
56     {
57             document.form1.email.focus();
58             document.form1.email.
select();
59             alert(
"Email length cannot be less than 8 characters");
60             
return false;
61     }
62          
if(ml.indexOf("@")==-1)
63         {
64             document.form1.email.focus();
65             document.form1.email.
select();
66             alert(
"The Email Address must contain '@' sign");
67             
return false;
68         }
69          
if(pos1<1)
70         {
71             document.form1.email.focus();
72             document.form1.email.
select();
73             alert(
"Email address cannot start with '@' sign");
74             
return false;
75         }
76         
else if(ml.indexOf(".")==-1)
77         {
78             document.form1.email.focus();
79             document.form1.email.
select();
80             alert(
"The Email Address must contain '.' sign");
81             
return false;
82         }
83         
if(pos!=-1)
84         {
85             document.form1.email.focus();
86             document.form1.email.
select();
87             alert(
"The Email Address cannot contain spaces");
88             
return false;
89         }
90         
if(server.indexOf("@")!=-1)
91         {
92             document.form1.email.focus();
93             document.form1.email.
select();
94             alert(
"A valid Email must contain only one '@' sign");
95             
return false;
96         }
97         
if(server.indexOf(".")==0)
98         {
99             document.form1.email.focus();
100             document.form1.email.
select();
101             alert(
"There should some text between '@' and '.' sign");
102             
return false;
103         }
104         
if(reqtype=="")
105         {
106             document.form1.email.focus();
107             document.form1.email.
select();
108             alert(
"Email Id should end with character(like .com,.net,.org)");
109             
return false;
110         }
111          
if(type_end.toUpperCase()<"A" || type_end.toUpperCase()>"Z")
112         {
113             document.form1.email.focus();
114             document.form1.email.
select();
115             alert(
"Email Id should not end with number or symbol");
116             
return false;
117         }

118 if
(document.form1.address.value=="")
119 {
120     alert(
"Enter the Address");
121     document.form1.address.focus();
122     
return false;
123 }

124 if
(document.form1.city.value=="")
125 {
126     alert(
"Enter the City");
127     document.form1.city.focus();
128     
return false;
129 }

130 if
(document.form1.zip.value=="")
131 {
132     alert(
"Enter the Zip");
133     document.form1.zip.focus();
134     
return false;
135 }

136 if
(document.form1.phone.value=="")
137 {
138     alert(
"Enter Phone No");
139     document.form1.phone.focus();
140     
return false;
141 }

142 if
(document.form1.mobile.value=="")
143 {
144     alert(
"Enter Mobile Number");
145     document.form1.mobile.focus();
146     
return false;
147 }
148 }
149 </script>
150
151
152 <?php
153 include(
"dbconnection.php");
154
155 if
(isset($_POST["submit"]))
156 {
157   $sql =
"update customer set fname='$_POST[custname]', lname='$_POST[lastname]', emailid='$_POST[custemailid]',address='$_POST[address]',city='$_POST[city]',zipcode='$_POST[zipcode]', contactno1='$_POST[contactno]',contactno2='$_POST[contactno2]' where custid='$_GET[custid]'";
158   $ctins =
1;
159   
if (!mysql_query($sql,$con))
160   {
161   die(
'Error: ' . mysql_error());
162   }
163 }

164 if
($ctins == 1)
165 {
166     echo
"<center><b>Your account Updated successfully...</b></center><br>";
167 }

168 else

169 {

170
171 if
($_GET['custid'])
172 {
173     $result = mysql_query(
"select * from customer where custid='$_GET[custid]'");
174     $row = mysql_fetch_array($result);
175     $fname = $row[
'fname'];
176     $lname = $row[
'lname'];
177     $emailid = $row[
'emailid'];
178     $contactno1 = $row[
'contactno1'];
179     $contactno2 = $row[
'contactno2'];
180 }
181
182 ?>
183
184
185
186         <div id=
"main">
187
188             <a name=
"TemplateInfo"></a>
189             <h1>service</h1>
190         <form id=
"form1" name="form1" method="post" action="" onsubmit="return validate()">
191             <table width=
"563" border="0">
192               <tr>
193                 <th width=
"266" height="33" scope="row">Customer Name</th>
194                 <td width=
"287">
195                   <label
for="fname"></label>
196                   <label
for="custname"></label>
197                 <input type=
"text" name="custname" value="<?= $fname; ?>" id="custname" onKeyPress="return isNumberKey(event)" /></td>
198               </tr>
199               <tr>
200                 <th height=
"37" scope="row">Last Name
201                   <label
for="lname"></label></th>
202                 <td><label
for="lastname"></label>
203                 <input type=
"text" name="lastname" value="<?= $lname; ?>" id="lastname" onKeyPress="return isNumberKey(event)"/></td>
204               </tr>
205               <tr>
206                 <th height=
"37" scope="row">Email ID</th>
207                 <td><input type=
"text" name="custemailid" value="<?= $emailid; ?>" id="custemailid" /></td>
208               </tr>
209               <tr>
210                 <th height=
"37" scope="row">Address</th>
211                 <td><textarea name=
"address"><?php echo $address; ?></textarea></td>
212               </tr>
213
214               <tr>
215                 <th height=
"37" scope="row">City</th>
216                 <td><input type=
"text" name="city" value="<?= $city; ?>" id="contactno" /></td>
217               </tr>
218
219               <tr>
220                 <th height=
"37" scope="row">Zip code</th>
221                 <td><input type=
"text" name="zipcode" value="<?= $zipcode; ?>" id="contactno" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;"/></td>
222               </tr>
223
224               <tr>
225                 <th height=
"37" scope="row">Contact No.</th>
226                 <td><input type=
"text" name="contactno" value="<?= $contactno1; ?>" id="contactno" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;"/></td>
227               </tr>
228
229
230              <tr>
231                 <th height=
"40" scope="row">Mobile Number</th>
232                 <td><label
for="confpass"></label>
233                   <label
for="images"></label>
234                   <label
for="contactno2"></label>
235                  <input type=
"text" name="contactno2" value="<?= $contactno2; ?>" id="contactno2" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;"/></td>
236               </tr>
237               <tr>
238                 <th scope=
"row">&nbsp;</th>
239                 <td><input type=
"submit" name="submit" id="submit" value="Update" /></td>
240               </tr>
241           </table>
242 </form>
243 <?php
244 }
245 ?>
246             <p>&nbsp;</p>
247 <br />
248
249         </div>
250
251 <!-- wrap ends here -->
252 </div>
253
254 <?php
255 include(
"footer.php");
256 ?>


Gõ tìm kiếm nhanh...